﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace UcAsp.WorkFrame
{
    public class ClearHTML
    {
        public static string Clear(string str)
        { 
            if(string.IsNullOrEmpty(str))
                return "";
            else{
                 return Regex.Replace(str, @"<[^>]*>", string.Empty, RegexOptions.IgnoreCase);
            }
        }
        public static string ClearP(string str)
        {
            if (string.IsNullOrEmpty(str))
                return "";
            else
            {
                return str.ToLower().Replace("<p>", "").Replace("</p>", ""); ;
            }
        }
        public static string CreateUrl(string tag)
        {
            string url = string.Empty;
            if (string.IsNullOrEmpty(tag))
                return "";
            else
            {
                string[] t = tag.Split(' ');
                for (int i = 0; i < t.Length; i++)
                {
                    if (!string.IsNullOrEmpty(t[i].Trim()))
                    {
                        url = url + "  <a href=\"/search/" + t[i] + "/1\">" + t[i] + "</a>";
                    }
                }
                return url;
            }
        }
        public static string CreateText(string str, int num)
        {
            if (str.Length > num)
            {
                return Clear(str).Substring(0, num);
            }
            else
            {
                return Clear(str);
            }
        }
    }
}
